const { ESRCH } = require("constants");
const http = require("http");

const server = http.createServer((req, res) => {
  // 设置响应的header

  // 设置方式1
  // res.setHeader("Content-Type", "text/html;charset=utf8");

  // 设置方式2
  res.writeHead(200, { "Content-Type": "text/html;charset=utf8" });

  res.end("<h2>Hello Server</h2>");
});

server.listen(8000, "0.0.0.0", () => {
  console.log("服务器启动成功");
});
